<template>

<div>
    <div>
        <h2>主页</h2>
    </div>
   <div>
      <van-button @click="aaa">我的订单</van-button>  
    </div>
    <div class="a" v-for="i,j in goodlist" :key="j">
    <van-image
    width="200"
    height="100"
    :src="i.img"
    /> <br>
    {{i.name}} <br>
    <span v-if="!uid">原价：{{i.price}}</span><span v-if="uid">会员价：{{i.vip_price}}</span> <van-button @click="shopping(i.id,i.vip_price)">立即预订</van-button>
    </div><br><br><br><br>
    
    
</div>
  
</template>

<script>
export default {
    data(){
        return{
            goodlist:'',
            uid:localStorage.getItem('ks_uid')||'',
        }
    },
    methods:{
        get_goods(){
        this.myaxios(this.baseURL + 'goods/','get',{username:this.username,password:this.password}).then(resp=>{
        console.log('预约',resp)
        if(resp.errcode==0){
          this.goodlist = resp.data
          
        }
      })
        },
        shopping(gid,price){
            if(!this.uid){
                window.location.href = '/ks_login'
            }else{
                window.location.href = '/ks_shopp?gid='+gid+'&price='+price
            }
        },
        aaa(){
           if(!this.uid){
                window.location.href = '/ks_login'
            }else{
                window.location.href = '/ks_myorder'
            } 
        }

     
    },
    mounted(){
        this.get_goods()
    }

}
</script>

<style>
.a{
    width: 30%;
    float: left;
}

</style>